<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/order_list.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/user/buyer_index.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/user/record.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/user/safe.css')}}">
    <script>
        var today = '{{date('Y-m-d')}}';
        var tomorrow = '{{date('Y-m-d',strtotime('+1 day'))}}';
    </script>
    <script src="{{asset('/js/web/user/record.js')}}"></script>
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="user_message">
                <div class="user_left">
                    <div class="img fl">
                        @if(isset($info['pic'])&&$info['pic']!=null)
                        <img src="{{array_get($info,'pic')}}">
                        @endif
                    </div>
                    <div class="right_account">
                        <a href=""><div class="account_name fl">{{array_get($info,'name')}}</div></a>
                        <div class="account_safe">
                            <div class="account_title">账号安全：</div>
                            <div class="level fl">
                                <?php
                                    $level = 0;
                                    if(array_get($info,'email')) $level += 0.5;
                                    if(array_get($info,'pay_pwd')) $level += 0.5;
                                ?>
                                <input type="hidden" id="level" name="" value="{{$level}}">
                                <span></span>
                            </div>
                            <span class="level_word">较低</span>
                            <a href="{{asset('/member/user/safe')}}" class="away_height">去提升</a>
                        </div>
                        <div class="account_my">
                            <a href="{{asset('/member/address')}}" class="my_adderss">我的收货地址</a>
                            <a href="{{asset('/member/buyer/invoices')}}" class="my_adderss">我的发票信息</a>
                        </div>
                    </div>
                    <div class="left_right_top"></div>
                    <div class="left_right_bottom"></div>
                </div>
                <div class="user_right">
                    <div class="right_left_top"></div>
                    <div class="right_left_bottom"></div>
                    <ul>
                        <li class="user_right_list">
                            <img class="user_right_img"src="{{asset('/img/web/user/fukuan.png')}}" alt="">
                            <a href="{{asset('/member/buyer/orders?order_status=1')}}"><p class="user_right_money">待付款<span>{{array_get($count,'NoPay')}}</span></p></a>
                        </li>
                        <li class="user_right_list">
                            <img class="user_right_img"src="{{asset('/img/web/user/fahuo.png')}}" alt="">
                            <a href="{{asset('/member/buyer/orders?order_status=2')}}"><p class="user_right_money">待发货<span>{{array_get($count,'Payed')}}</span></p></a>
                        </li>
                        <li class="user_right_list">
                            <img class="user_right_img"src="{{asset('/img/web/user/shouhuo.png')}}" alt="">
                            <a href="{{asset('/member/buyer/orders?order_status=3')}}"><p class="user_right_money">待收货<span>{{array_get($count,'Delivery')}}</span></p></a>
                        </li>
                        <li class="user_right_list">
                            <img class="user_right_img"src="{{asset('/img/web/user/pingjia.png')}}" alt="">
                            <a href="{{asset('/member/buyer/orders?order_status=4')}}"><p class="user_right_money">待评价<span>{{array_get($count,'Comment')}}</span></p></a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="news_orders">
                <div class="news_top">
                    <h2 class="news_order">最新订单</h2>
                    <a href="{{asset('/member/buyer/orders')}}"><h3 class="all_order">全部订单</h3></a>
                </div>
                <div class="tit f-cb">
                    <div class="pr fl" style="width:345px;">订单商品</div>
                    <div class="pes fl" style="width:145px;">数量 </div>
                    <div class="mon fl" style="width:145px;">金额</div>
                    <div class="sta fl" style="width:145px;">订单状态</div>
                    <div class="op fl" style="width:175px;">操作</div>
                </div> 
                <div class="content">
                    <div class="order">

                        @if(isset($order['order_products'][0]))
                        <div class="boxtop f-cb">
                            {{--<input type="checkbox" class="check fl">--}}
                            <div class="number fl">订单编号：<a href="/member/buyer/orders/{{$order['id']}}">{{array_get($order,'order_code')}}</a></div>
                            <a href="javascript:;" class="delete flr" data-id=></a>
                            <div class="time flr" style="line-height: 38px;">下单时间：{{date('Y/m/d', strtotime($order['created_at']))}}</div>
                        </div>
                        <div class="info">
                            <table>
                                <tr>
                                    <td width="70" height="100" class="imgbox">

                                        @if($order['order_type'] == 1)
                                            <a target='_blank' href="/product/info/{{$order['order_products'][0]['product_id']}}/{{$order['order_products'][0]['sku_id']}}">
                                                <img src="{{$order['order_products'][0]['product_img_url']}}" width="80" height="80">
                                            </a>
                                        @else
                                            <img src="{{$order['order_products'][0]['product_img_url']}}" width="80" height="80">

                                        @endif

                                    </td>
                                    <td width="246" height="100" class="goods_name_box">
                                        <div class="goods_name">
                                            @if($order['order_type'] == 1)
                                                <a target='_blank' href="/product/info/{{$order['order_products'][0]['product_id']}}/{{$order['order_products'][0]['sku_id']}}">
                                                    {{$order['order_products'][0]['product_name']}}
                                                </a>
                                            @else
                                                {{$order['order_products'][0]['product_name']}}
                                            @endif

                                        </div>
                                    </td>
                                    <td width="145" height="100" class="num" >{{$order['order_products'][0]['quantity']}}</td>
                                    <td width="150" height="100" class="price" rowspan="">
                                        <div class="cost">
                                            <span class="tt"><span class="rmb">￥</span>{{$order['order_money']}}</span>
                                        </div>
                                    </td>
                                    <td width="150" height="100" class="statebox" rowspan="">
                                        @if($order['order_status'] == 1)
                                            <div>等待买家付款</div>
                                        @elseif($order['order_status'] == 2)
                                            <div>待发货</div>
                                        @elseif($order['order_status'] == 3)
                                            <div>等待收货</div>
                                        @elseif($order['order_status'] == 4)
                                            <div>已完成</div>
                                        @elseif($order['order_status'] == 5)
                                            <div>已取消</div>
                                        @endif
                                        {{--
                                            <div>退款申请中</div>
                                            <div>同意退款，退款中</div>
                                            <div>退款已拒绝</div>
                                            <div>退款完成</div>
                                        --}}
                                        <a href="/member/buyer/orders/{{$order['id']}}" class="close jm_hover">订单详情</a>
                                    </td>
                                    <td width="150" height="100" class="paybox" rowspan="">
                                        <div class="btnbox">
                                            @if($order['order_status'] == 1)
                                                <a href="/member/buyer/pay?order_codes={{$order['order_code']}}" class="btn jm_btn8">立即付款</a>
                                                <a href="javascript:;" class="order_cancel" data-id="{{$order['id']}}">取消订单</a>
                                            @elseif($order['order_status'] == 2)
                                                <div>等待卖家发货</div>
                                            @elseif($order['order_status'] == 3)
                                                <a href="javascript:;" class="order_confirm btn jm_btn8" data-id="{{$order['id']}}">确认收货</a>
                                                <a href="javascript:;" class="logistics_info" data-id="{{$order['id']}}">查看物流</a>
                                            @elseif($order['order_status'] == 4)
                                                @if($order['buyer_comment_status']==0)
                                                <a href="/member/buyer/orders/{{$order['id']}}/comments/create" data-id='{{$order['id']}}' class="btn jm_btn8">评价</a>
                                                @else
                                                已评价
                                                @endif
                                            @elseif($order['order_status'] == 5)
                                                <div>已取消</div>
                                            @endif
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        @else
                            <p class="text-center">暂无订单信息</p>
                        @endif
                    </div>
                </div>
            </div>
            <div class="news_matching_list">
                <div class="news_matching_top">
                   <h2 class="news_matching_order">最新配单</h2> 
                   <a href="{{url('/member/buyer/items')}}"><h3 class="all_matching_list">全部配单</h3></a>
                </div>
                @if(!empty($items))
                    <div class="confirm" style="display:block;">
                        <div class="confirm_left">
                            <h4 class="confirm_wait">{{$items['order_status_name']}}</h4>
                            <p class="confirm_num">配单编号：{{$items['order_code']}} |  <span>创建时间：{{$items['created_at']}}</span> | <i>
                                    @if(in_array(1,$items['items_information']['quote_contain']))
                                       含税
                                   @elseif(in_array(2,$items['items_information']['quote_contain']))
                                       含运费
                                   @elseif(in_array(3,$items['items_information']['quote_contain']))
                                       含施工安装
                                   @elseif(in_array(4,$items['items_information']['quote_contain']))
                                       含公报总价
                                   @endif
                                </i></p>
                        </div>
                         <div class="confirm_right">
                            <p class="confirm_money">合计金额：<span>{{$items['order_money']}}</span><i>元</i></p>
                        </div>
                    </div>
                    <h5 class="news_matching_seve" style="display:block;">服务专员:{{$items['items_information']['seller_phone']}}（{{$items['items_information']['seller_contact']}}）</h5>
                    <a href="{{url('/member/buyer/orders')}}/{{$items['id']}}"><p class="confirm_away" style="display:block;">立即查看</p></a>
                @endif
            </div>
            <div class="nav_right flr">
                <div class="base_content">
                    <div class="line_title">浏览记录</div>
                    <div class="today">
                        <div class="my-subnav f-cb">
                            <div class="day fl">今天</div>
                            <div class="time fl">{{ date('Y.m.d') }}</div>
                            <div class="delete fl">
                                <a class="del-today" style="display:none;" href="javascript:void(0);">删除</a>
                            </div>
                        </div>
                        <div class="content" style="display:none;">
                            <div class="list">
                                <ul>
                                @if(!empty($today_data))
                                    @foreach($today_data as $d)
                                    <li>
                                        <div class="data_delete">
                                            <img src="{{asset('/img/inc/icon/close2.png')}}" alt=""/>
                                        </div>
                                        <div class="data_delete2"  data-id="{{$d['history_id']}}">
                                            <img src="{{asset('/img/inc/icon/close3.png')}}" alt=""/>
                                        </div>
                                        <div class="imgbox">
                                            <a href="/product/info/{{$d['product_id']}}/{{$d['sku_id']}}" target="_blank">
                                                <img src="{{$d['cover_image']}}" alt="">
                                            </a>
                                        </div>
                                        <div class="price">￥{{number_format($d['price'],2)}}</div>
                                        <div class="name">
                                            <a href="/product/info/{{$d['product_id']}}/{{$d['sku_id']}}" target="_blank">{{$d['name']}}</a>
                                        </div>
                                    </li>
                                    @endforeach
                                @endif
                                </ul>
                            </div>
                        </div>
                       
                    </div>
                    <div class="today_before">
                        <div class="my-subnav f-cb">
                            <div class="day fl">更早以前</div>
                            <div class="delete fl">
                                <a class="del-earlier" style="display:none;" href="javascript:void(0);">删除</a>
                            </div>
                        </div>
                        <div class="content" style="display:none;">
                            <div class="list">
                                <ul>
                                @if(!empty($earlier_data))
                                    @foreach($earlier_data as $d)
                                        <li>
                                            <div class="data_delete">
                                                <img src="{{asset('/img/inc/icon/close2.png')}}" alt=""/>
                                            </div>
                                            <div class="data_delete2"  data-id="{{$d['history_id']}}">
                                                <img src="{{asset('/img/inc/icon/close3.png')}}" alt=""/>
                                            </div>
                                            <div class="imgbox">

                                                <a href="/product/info/{{$d['product_id']}}/{{$d['sku_id']}}" target="_blank">
                                                    <img src="{{$d['cover_image']}}" alt="">
                                                </a>
                                            </div>
                                            <div class="price">￥{{number_format($d['price'],2)}}</div>
                                            <div class="name">
                                                <a href="/product/info/{{$d['product_id']}}/{{$d['sku_id']}}" target="_blank">{{$d['name']}}</a>
                                            </div>
                                        </li>
                                    @endforeach
                                @endif
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@include('web.layout.footer')
<script>
   $(function () {
      var level = $('#level').val();
      $('.level span').css("width",level*100+'%');
      if(level == 0){
          $('.level_word').html('较低');
      }else if(level ==0.5 ){
          $('.level_word').html('中等');
      }else if(level == 1 ){
          $('.level_word').html('完善');
      }
    });
   //url定义
   var express_url = "/member/seller/orders/{id}/order_express/0";
   var order_update = '/member/buyer/orders/{id}';
   var order_cancel = "";
   $(".order_cancel").on('click', function(event) {
       event.preventDefault();
       /* Act on the event */
       var order_id = $(this).data('id');
       var url = order_update.replace('{id}', order_id);
       layer.confirm('是否取消订单', {
           btn: ['确认', '取消'] //可以无限个按钮
       }, function (index) {
           $.ajax({
               url: url,
               type: 'PUT',
               dataType: 'json',
               data: {order_status: 5},
               success:function(data){
                   if(0==data.code){
                       layer.alert('取消成功！', {
                           icon: 1
                       }, function () {
                           window.location.reload();
                       });
                   }else{
                       alert(data.message);
                   }
               }
           });
       }, function (index, layero) {
           layer.close(index);
       });

   });

   $(".order_confirm").on('click', function(event) {
       event.preventDefault();
       var order_id = $(this).data('id');
       var url = order_update.replace('{id}', order_id);
       layer.confirm('是否确认收货', {
           btn: ['确认', '取消'] //可以无限个按钮
       }, function (index) {
           /* Act on the event */
           $.ajax({
               url: url,
               type: 'put',
               dataType: 'json',
               data: {order_status:4},
               success:function(data){
                   if(0==data.code){
                       window.location.reload();
                   }else{
                	   layer.alert(data.message, {
                           icon: 0
                       }, function () {
                           window.location.reload();
                       });
                   }
               }
           });
       }, function (index, layero) {
           layer.close(index);
       });
   });

   //查看物流信息
   $('.logistics_info').click(function(){
       var order_id = $(this).data('id');
       var url = express_url.replace('{id}', order_id);
       $.get(
               url,
               {},
               function (data) {
                   $('html').append(data);
               }
       );
   });
</script>
</body>
</html>